/*  This file is part of -_-.

    -_- is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    -_- is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with -_-.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2012-2013 Oliver Katz */

#include "../../common/debug.h"
#include "../../arch/arch.h"
#include "../../arch/modules/mod_argbuf.h"
#include "../../arch/modules/mod_bus.h"
#include "../../arch/modules/mod_codeserver.h"
#include "../../arch/modules/mod_log.h"
#include "../../arch/modules/mod_share_client.h"
#include "../../arch/modules/mod_share_server.h"

using namespace sleepyface;
using namespace sleepyface::arch;

int main(int argc, char *argv[])
{
    Z_DEBUG_INIT(argv[0]);

	Architecture arch = Architecture("-_-buildable");
    
	arch.loadRequiredInternals();

    ((modules::ArgumentBuffer *)arch.module("argument-buffer"))->add("input", 0, "", "", arch);

	arch.loadOptionalInternals(argc, argv);

    string input = arch.module("argument-buffer")->get("input", "value", arch).getString();
    if (!input.empty())
    {
        ModuleSignal s = ModuleSignal(modules::CodeServer::signalCompileFile);
        s.append(ModuleValue(ModuleValue::_string, input));
        arch.module("code-server")->signal(s, arch);
    }

    return arch.module("code-server")->signal(ModuleSignal(modules::CodeServer::signalShell), arch);
}
